package com.zft.userwalletmanager.application.service;

import com.zft.userwalletmanager.domain.bo.WalletBO;
import com.zft.userwalletmanager.infrastructure.gateway.database.dao.AccountFlowDAO;
import com.zft.userwalletmanager.infrastructure.gateway.database.model.AccountFlowDO;
import com.zft.userwalletmanager.web.response.AccountFlowDetailsResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class AccountFlowService {
    @Autowired
    private AccountFlowDAO accountFlowDAO;

    /**
     * 插入账务流水
     * @param walletBO
     */
    public void insertAccountFlow(WalletBO walletBO) {
        if (Objects.isNull(walletBO)) {
            throw new IllegalArgumentException("AccountFlowService||insertAccountFlow||wallet is null");
        }
        accountFlowDAO.insertAccountFlow(walletBO);
    }

    /**
     * 查找账务流水
     * @param orderId
     * @return
     */
    public com.zft.userwalletmanager.infrastructure.gateway.database.model.AccountFlowDO selectAccountFlowByOrderId(String orderId) {
        if (StringUtils.isBlank(orderId)) {
            throw new IllegalArgumentException("AccountFlowService||selectAccountFlow||orderId is null");
        }
        return accountFlowDAO.selectAccountFlowByOrderId(orderId);
    }

    public List<AccountFlowDO> selectAccountFlowByWalletNo(String walletNo) {
        if (StringUtils.isBlank(walletNo)) {
            throw new IllegalArgumentException("AccountFlowService||selectAccountFlowByWalletNo||walletNo is null");
        }
        return accountFlowDAO.selectAccountFlowByWalletNo(walletNo);
    }
}
